from app.extensions import db
from datetime import datetime

class MarineData(db.Model):
    __tablename__ = 'marine_data'
    
    id = db.Column(db.Integer, primary_key=True)
    marine_area_id = db.Column(db.Integer, db.ForeignKey('marine_areas.id'))
    data_type = db.Column(db.Enum('temperature', 'pressure', 'wave'), nullable=False)
    value = db.Column(db.DECIMAL(10, 2), nullable=False)
    latitude = db.Column(db.DECIMAL(10, 6))  # 对温度数据需要位置信息
    longitude = db.Column(db.DECIMAL(10, 6))
    measurement_time = db.Column(db.DateTime, nullable=False)
    is_predicted = db.Column(db.Boolean, default=False)  # 标记是否为预测数据
    created_at = db.Column(db.DateTime, default=datetime.utcnow)

    marine_area = db.relationship('MarineArea', backref='marine_data') 